package com.bll.imple.plateAction;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bean.PlateBean;
import com.bean.UserBean;
import com.bll.Action;
import com.dao.PlateDao;
import com.dao.SweepstakeDao;
import com.dao.UserDao;

public class AddPlateAction implements Action{

	public String execute(HttpServletRequest request,
			HttpServletResponse response) {
		int userId=Integer.parseInt(request.getSession().getAttribute("userId").toString());
		System.out.println("userId:"+userId);
		UserDao dao=new UserDao();
		UserBean bean=dao.selectById(userId);
		String username=bean.getName();
		String num=bean.getTel();
		System.out.println("username:"+username);
		System.out.println("num:"+num);
		PlateBean plbean=new PlateBean();
		PlateDao pldao=new PlateDao();
		//SweepstakeDao swdao=new SweepstakeDao();
		
		plbean.setUserid(userId);
		plbean.setPhonenum(num);
		plbean.setUsername(username);
		String prize=request.getParameter("result");
		System.out.println("prize:"+prize);
		plbean.setPrize(prize);
		if(pldao.addPlate(plbean)>0){
			return "ShowfModule.mod?lujing=shouye.jsp";
		}else{
			System.out.println("falied------------");
		}
		return null;
	}
	
}
